<template>
  <view class="orderDetail">
    <!-- <nut-watermark :z-index="999" content="小刘"></nut-watermark> -->
    <nut-cell-group title="订单详情">
      <nut-cell title="订单编号：">
        <template #desc>
          <span>{{orderInfo.o_order_code}}</span>
        </template>
      </nut-cell>
      <nut-cell title="眼镜数量：">
        <template #desc>
          <span>{{orderInfo.o_glasses_num}}</span>
        </template>
      </nut-cell>
      <nut-cell title="已还镜数量:">
        <template #desc>
          <span>{{orderInfo.f_num || 0}}</span>
        </template>
      </nut-cell>
      <nut-cell title="场地名称:">
        <template #desc>
          <span>{{orderInfo.f_field_name}}</span>
        </template>
      </nut-cell>
      <nut-cell title="设备编码:">
        <template #desc>
          <span>{{orderInfo.o_equipment_code}}</span>
        </template>
      </nut-cell>
      <nut-cell title="租户名称:">
        <template #desc>
          <span>{{orderInfo.user_telphone}}</span>
        </template>
      </nut-cell>
      <nut-cell title="使用区域：">
        <template #desc>
          <span>{{orderInfo.o_area}}</span>
        </template>
      </nut-cell>
      <nut-cell title="是否退款：">
        <template #desc>
          <nut-tag v-if="orderInfo.o_is_refund == -1" type="success">已退款</nut-tag>
          <nut-tag v-else-if="orderInfo.o_is_refund == 1" type="warning">退款中</nut-tag>
          <nut-tag v-else-if="orderInfo.o_is_refund == 0" type="danger">未退款</nut-tag>
        </template>
      </nut-cell>
      <nut-cell title="归还状态：">
        <template #desc>
          <nut-tag v-if="orderInfo.o_status == 3" type="success">已还镜</nut-tag>
          <nut-tag v-else-if="orderInfo.o_status == 4" type="warning">部分还镜</nut-tag>
          <nut-tag v-else-if="orderInfo.o_status == 2" type="danger">未归还</nut-tag>
        </template>
      </nut-cell>
      <nut-cell title="订单时间：">
        <template #desc>
          <span>{{orderInfo.o_start_time}}</span>
        </template>
      </nut-cell>
      <nut-cell title="订单金额：">
        <template #desc>
          <span>{{orderInfo.o_money}}</span>
        </template>
      </nut-cell>
      <nut-cell title="支付时间：">
        <template #desc>
          <span>{{orderInfo.o_pay_time}}</span>
        </template>
      </nut-cell>
      <nut-cell title="退款金额：">
        <template #desc>
          <span>{{orderInfo.refund_fee}}</span>
        </template>
      </nut-cell>
      <nut-cell title="退款时间：">
        <template #desc>
          <span>{{orderInfo.refund_time}}</span>
        </template>
      </nut-cell>
      <nut-cell title="退款原因：">
        <template #desc>
          <span>{{orderInfo.refund_reason}}</span>
        </template>
      </nut-cell>
    </nut-cell-group>
    <scroll-view :scroll-x="true" style="width: 100%;">
      <nut-table :columns="columns" :data="orderInfo.o_content"></nut-table>
    </scroll-view>
    
    <nut-cell-group title="眼镜借出详情"></nut-cell-group>
    <scroll-view :scroll-x="true" style="width: 100%;">
      <nut-table style="width: 200%;" :columns="Glasscolumns" :data="orderInfo.glasses_data"></nut-table>
    </scroll-view>
    
  </view>
</template>

<script setup>
import './index.scss';
import { ref, computed } from 'vue';
import { IconFont } from '@nutui/icons-vue-taro'
import { My } from '@nutui/icons-vue-taro'
import Taro, {useDidShow} from '@tarojs/taro'
import {query_order_info} from '../../https/api'


const orderInfo = ref({})
const columns = ref([
  {
    title: '眼镜类别',
    key: 't_type_name'
  },
  {
    title: '目标人群',
    key: 't_target_customers'
  },
  {
    title: '押金',
    key: 't_deposit'
  },
  {
    title: '眼镜借出数量',
    key: 'num'
  }
])

const Glasscolumns = ref([
{
    title: '眼镜类别',
    key: 'glasses_type'
  },
  {
    title: '眼镜编码',
    key: 'go_code'
  },
  {
    title: '借出时间',
    key: 'go_output_time'
  },
  {
    title: '归还时间',
    key: 'go_input_time'
  },
  {
    title: '眼镜归还状态',
    key: 'go_status'
  },
])
const getOrderDetail = (code) => {
  query_order_info({o_order_code: code}).then(res => {
    let arr =res.data.glasses_data
    if (arr.length) {
      for(let i in arr) {
        for(let key in arr[i] ) {
          if (key == 'go_status') {
            arr[i][key] = arr[i][key] == 1 ? '已还镜' : '未还镜'
          }
        }
      }
      res.data.glasses_data = arr
    }
   
    
    orderInfo.value = res.data
  })
}
useDidShow(() => {
  let params =Taro.getCurrentInstance().router.params
  // 'GO20240629210853974634sfi36u'
  getOrderDetail(params.orderCode)
})
</script>

<style>
</style>